Understanding Secure Data
Provides a secure wrapper around sensitive string data, using byte arrays and constant-time comparison to prevent memory leaks and timing attacks. Supports secure conversion from and to strings, with explicit clearing of sensitive data in memory.
A readonly struct that holds sensitive byte data and provides secure conversions, disposal, and constant-time equality.
Fields:
Methods:
SecureData
instance from a string and clears the original.==
operator.SecureData
.(TL;DR? Doing any equality check on SecureDatas automatically overrides the default system way with a more secure version. Use plainPassword.ToSecureData() to get a SecureData object from a string, then use securePassword.ConvertToString() to get the original string back. You should be able to use the BinaryConverter to format any item to bytes, then encode it with UTF8 into a string before turning it into SecureData. It's reccomended to do this with smaller variables instead of large ones. However, if you need larger variables to be saved like this, remember to use async/threading principles to ensure you don't accidently freeze your program.)
Provides extension methods for safely converting and clearing sensitive string data.
SecureData
and securely clears the original.Interned Example - string interned = "sensitive";
Non Interned Example - string nonInterned = new string("sensitive".ToCharArray());